#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[100005];

signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	int ans = INT_MAX, sum = INT_MAX;
	for (int i = 1; i <= n; i++) {
		ans = min(sum, ans);
		if (i + m - 1 > n)	break;
		sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i + j];
		}
	}
	if (!n)
		cout << n;
	else
		cout << ans;
	return 0;
}
